﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ctChangePermission.ascx.cs" Inherits="KhoaLuan.MainSys.Manager.Controls.ctChangePermission" %>
<link href="/Style/StyleCommon.css" rel="stylesheet" />
<link href="/Style/modal.css" rel="stylesheet" />
<script src="/Scripts/dluscript.js"></script>
<script type="text/javascript">
    function SaveData() {
        var groupid = GetQueryStringHref("GroupID");
        var listpowerid = $("tr[datatype='power']");
        var listview = $("input[datatype='view']");
        var listadd = $("input[datatype='add']");
        var listedit = $("input[datatype='edit']");
        var listdel = $("input[datatype='del']");
        var powerid = [], menuid = [], view = [], add = [], edit = [], del = [];
        for (var i = 0; i < listpowerid.length; i++) {
            debugger;
            powerid.push(parseInt($(listpowerid[i]).attr('dataid')));
            menuid.push(parseInt($(listpowerid[i]).attr('menuid')));
            view.push(listview[i].checked);
            add.push(listadd[i].checked);
            edit.push(listedit[i].checked);
            del.push(listdel[i].checked);
        };
        CallAjaxAspx("POST", "SaveChangePermission", "/MainSys/ProcessAJAX/AjaxPower.aspx", {
            groupid: groupid == null ? 0 : groupid,
            powerid: powerid,
            menuid: menuid,
            view: view,
            edit: edit,
            del: del,
            add: add
        }, function (response) {
            var obj = JSON.parse(response);
            if (obj.Status) {
                alertSmallBox("Cập nhật thành công!", "1 giây trước", "success");
                location.replace("/MainSys/Manager/Admin.aspx");
            }
            else {
                alertSmallBox("Cập nhật thất bại!", "1 giây trước", "error");
            }
        }, AjaxLoading(true), AjaxLoading(false));
    }
</script>
<section id="widget-grid" class="">
    <div class="row">
        <article class="col-sm-12 col-md-12 col-lg-12">
            <div class="jarviswidget jarviswidget-color-blueDark" id="wid-id-1" data-widget-editbutton="false" data-widget-fullscreenbutton="false">
                <header>
                    <h2>PHÂN QUYỀN CONTROL</h2>
                    <div class="widget-toolbar">
                        <div class="btn-group">
                            <input class="btn btnthem dropdown-toggle btn-xs btn-success" type="button" id="btnThem" runat="server" style="margin-right: 10px;" value="Add new" />
                            <input type="button" value="Show" class="btn btnthem dropdown-toggle btn-xs btn-success" id="btnShow" />
                        </div>
                    </div>
                </header>

                <div class="widget-body widget-hide-overflow padding">
                    <div class="col-xs-12 col-sm-12">
                        <div class="alert alert-info fade in">
                            <label runat="server" id="lbGroup"></label>
                        </div>
                    </div>

                    <div class="col-sm-12 smart-form">
                        <asp:Repeater runat="server" ID="repPermisson">
                            <HeaderTemplate>
                                <table id="tableListIntro" class="table table-bordered">
                                    <thead>
                                        <tr>
                                            <td style="width: 200px;">Control
                                            </td>
                                            <td>Path
                                            </td>
                                            <td style="width: 30px;">View
                                            </td>
                                            <td style="width: 30px;">Add
                                            </td>
                                            <td style="width: 30px;">Edit
                                            </td>
                                            <td style="width: 30px;">Delete
                                            </td>
                                        </tr>
                                    </thead>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <tr dataid="<%#Eval("PowerID") %>" menuid="<%#Eval("MenuID")  %>" datatype="power">
                                    <td>
                                        <%#Eval("MenuName") %>
                                    </td>
                                    <td>
                                        <%#Eval("Link") %>
                                    </td>
                                    <td style="vertical-align: top; text-align: center;">
                                        <label class="checkbox" style="margin-top: 0px;">
                                            <input type="checkbox" datatype="view" name="checkbox" <%#Convert.ToBoolean(Eval("View"))?"checked":""%> /><i>&nbsp</i>
                                        </label>
                                    </td>
                                    <td style="vertical-align: top; text-align: center;">
                                        <label class="checkbox" style="margin-top: 0px;">
                                            <input type="checkbox" datatype="add" name="checkbox" <%#Convert.ToBoolean(Eval("Add"))?"checked":""%> /><i>&nbsp</i>
                                        </label>
                                    </td>
                                    <td style="vertical-align: top; text-align: center;">
                                        <label class="checkbox" style="margin-top: 0px;">
                                            <input type="checkbox" datatype="edit" name="checkbox" <%#Convert.ToBoolean(Eval("Edit"))?"checked":""%> /><i>&nbsp</i>
                                        </label>
                                    </td>
                                    <td style="vertical-align: top; text-align: center;">
                                        <label class="checkbox" style="margin-top: 0px;">
                                            <input type="checkbox" name="checkbox" datatype="del" <%#Convert.ToBoolean(Eval("Del"))?"checked":""%> /><i>&nbsp</i>
                                        </label>
                                    </td>
                                </tr>
                            </ItemTemplate>
                            <FooterTemplate>
                                </table>
                            </FooterTemplate>
                        </asp:Repeater>
                        <footer>
                            <input type="button" value="Save" class="btn btn-primary" onclick="SaveData()" />
                            <input type="button" value="Cancel" onclick="history.back();" class="btn btn-default" />
                        </footer>
                        <div id="divpaging"></div>
                    </div>
                </div>
            </div>
        </article>
    </div>
</section>
